﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="hoatdongsx.aspx.cs" Inherits="Sanpham_hoatdongsx" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
     <style type="text/css">
        .MyImageButton
        {
           cursor: hand;
        }
        .EditFormHeader td
        {
            font-size: 14px;
            padding: 4px !important;
            color: #0066cc;
        }
        </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        
            <p id="divMsgs" runat="server">
        <asp:Label ID="Label1" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#FF8080"></asp:Label>
        <asp:Label ID="Label2" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#00C000"></asp:Label>
            </p>
            
         <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

            <script type="text/javascript">
            function RowDblClick(sender, eventArgs)
            {
              sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }
            </script>

        </telerik:RadCodeBlock>
       
        
        
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" 
            BackColor="#99FF66" Skin="WebBlue" />
        <telerik:RadGrid ID="RadGrid_hdsx" runat="server" AllowPaging="True" 
            AllowSorting="True" CellSpacing="0" DataSourceID="SqlDataSource_hdsx" 
            GridLines="None" AllowAutomaticDeletes="True" AutoGenerateColumns="False"
            AllowAutomaticInserts="True" AllowAutomaticUpdates="True" OnItemUpdated="RadGrid_hdsx_ItemUpdated"
             
           OnItemInserted="RadGrid_hdsx_ItemInserted" OnDataBound="RadGrid_hdsx_DataBound" Skin="Telerik">
                <HeaderContextMenu></HeaderContextMenu>

                <MasterTableView AutoGenerateColumns="False" DataKeyNames="mahd" 
                                DataSourceID="SqlDataSource_hdsx" CommandItemDisplay="Top">
                                
                <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                <HeaderStyle Width="20px"></HeaderStyle>
                </RowIndicatorColumn>

                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>

    <Columns>
    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        <ItemStyle CssClass="MyImageButton" />
                    </telerik:GridEditCommandColumn>
                    
        <telerik:GridBoundColumn DataField="mahd" DataType="System.Int32"  Visible="false"
            FilterControlAltText="Filter mahd column" HeaderText="mahd" ReadOnly="True" 
            SortExpression="mahd" UniqueName="mahd">
        </telerik:GridBoundColumn>
        
           <telerik:GridTemplateColumn HeaderText="STT">
                       <ItemTemplate>
                        <asp:Label runat="server" ID="lblSTT" Text='<%#i++%>'></asp:Label>
                       </ItemTemplate>
           </telerik:GridTemplateColumn>
        
       
        
        <telerik:GridDropDownColumn DataField="madnghiep" DataSourceID="hdsx_dn"
                        HeaderText="Doanhnghiep" ListTextField="TenDN" ListValueField="madnghiep"
                        UniqueName="madnghiep" ColumnEditorID="GridDropDownColumnEditor1">
        </telerik:GridDropDownColumn>
        
        <telerik:GridBoundColumn DataField="Tongdt" 
            FilterControlAltText="Filter Tongdt column" HeaderText="Tongdt" 
            SortExpression="Tongdt" UniqueName="Tongdt">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Nam" 
            FilterControlAltText="Filter Nam column" HeaderText="Nam" SortExpression="Nam" 
            UniqueName="Nam">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Socongnhan" 
            FilterControlAltText="Filter Socongnhan column" HeaderText="Socongnhan" 
            SortExpression="Socongnhan" UniqueName="Socongnhan">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Soca" 
            FilterControlAltText="Filter Soca column" HeaderText="Soca" 
            SortExpression="Soca" UniqueName="Soca">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Masan" 
            FilterControlAltText="Filter Masan column" HeaderText="Masan" 
            SortExpression="Masan" UniqueName="Masan">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Soluongsa" 
            FilterControlAltText="Filter Soluongsa column" HeaderText="Soluongsa" 
            SortExpression="Soluongsa" UniqueName="Soluongsa">
        </telerik:GridBoundColumn>
        
        <telerik:GridButtonColumn ConfirmText="Delete this Hoatdongsx?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn">
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
    </Columns>

            <EditFormSettings EditFormType="Template" ColumnNumber="2" CaptionDataField="madnghiep" CaptionFormatString="Edit properties of Product {0}" InsertCaption="New Hoatdongsx">
            
<EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column"></EditColumn>
            
                <FormTemplate>
                    <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
                        style="border-collapse: collapse; background: white;">
                        <tr class="EditFormHeader">
                            <td colspan="2" style="font-size: small">
                                <b>Them sp</b>
                            </td>
                        </tr>                      
                        
                             <tr>
                               <td>
                                <table id="Table3" cellspacing="1" cellpadding="1" width="250" border="0" class="module">
                                    <tr>
                                        <td>
                                        </td>
                                        <td>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                             Doanh nghiệp:<br />
                                            <asp:DropDownList ID="ddlTOC" runat="server" SelectedValue='<%# Bind("madnghiep") %>'
                                                DataTextField="TenDN" TabIndex="7" DataValueField="madnghiep" DataSourceID="hdsx_dn"
                                                AppendDataBoundItems="True">
                                                <asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
                                            </asp:DropDownList>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Doanh nghiệp chưa chọn" ControlToValidate="ddlTOC">
                                            </asp:RequiredFieldValidator>
                                               
                                        </td>
                                        
                                    </tr>
                                    <tr>
                                  <td>
                                        Tổng dt:<br />
                                            <asp:TextBox ID="txtTongdt" runat="server" Text='<%# Bind("Tongdt") %>'>
                                            </asp:TextBox>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                    ErrorMessage="* chua nhập sp" ControlToValidate="txtTongdt"></asp:RequiredFieldValidator>
                                        </td>
                                        
                                   </tr><tr>   
                                        <td>
                                        Năm:<br />
                                            <asp:TextBox ID="txtnam" runat="server" Text='<%# Bind("Nam") %>' TabIndex="1">
                                            </asp:TextBox>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                    ErrorMessage="* Chưa nhập Năm" ControlToValidate="txtnam"></asp:RequiredFieldValidator>
                                        </td>
                                    </tr>
                                    <tr>
                                       
                                        <td>
                                        Số công nhân:<br />
                                            <asp:TextBox ID="txtSocongnhan" runat="server" Text='<%# Bind("Socongnhan") %>' TabIndex="2">
                                            </asp:TextBox>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                    ErrorMessage="*" ControlToValidate="txtSocongnhan"></asp:RequiredFieldValidator>
                                        </td>
                                   </tr>
                                     
                                </table>
                            </td>
                          
                      
                        
                            <td>
                                <table id="Table4" cellspacing="1" cellpadding="1" width="250" border="0">
                                    <tr>
                                        
                                        <td>
                                        Số ca:<br />
                                            <asp:TextBox ID="txtSoca" Text='<%# Bind( "Soca") %>' runat="server" TabIndex="8">
                                            </asp:TextBox>
                                            
                                        </td>
                                    </tr>
                                    <tr>
                                       
                                        <td>
                                        Mã sàn:<br />
                                            <asp:TextBox ID="txtMasan" Text='<%# Bind( "Masan") %>' runat="server" TabIndex="9">
                                            </asp:TextBox>
                                        </td>
                                    </tr>
                                  
                                    <tr>
                                      
                                        <td>
                                        Số lượng sàn:<br />
                                            <asp:TextBox ID="txtdvi" Text='<%# Bind( "Soluongsa") %>' runat="server" TabIndex="11">
                                            </asp:TextBox>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                                             ErrorMessage="*" ControlToValidate="txtdvi"></asp:RequiredFieldValidator>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            </tr>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" colspan="2">
                                 <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                </asp:Button>&nbsp;
                                        <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                        CommandName="Cancel"></asp:Button>
                                  
                                 
                            </td>
                        </tr>
                    </table>
                </FormTemplate>
            </EditFormSettings>
           </MasterTableView>
           <ClientSettings EnableRowHoverStyle="true">
               <Selecting AllowRowSelect="True" />
               <ClientEvents OnRowDblClick="RowDblClick" />
           </ClientSettings>


<FilterMenu EnableImageSprites="False"></FilterMenu>
        </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource_hdsx" runat="server"
          ConnectionString="<%$ ConnectionStrings:QLMTConnectionString %>" ProviderName="System.Data.SqlClient"
          SelectCommand="SELECT * from [Hoatdongsx] where Madnghiep=@Madnghiep"
           DeleteCommand="DELETE FROM [Hoatdongsx] WHERE [mahd] = @original_mahd"
           InsertCommand="INSERT INTO Hoatdongsx(madnghiep, Tongdt,Nam,Socongnhan,Soca,Masan,Soluongsa) VALUES (@madnghiep,@Tongdt,@Nam,@Socongnhan,@Soca,@Masan,@Soluongsa)"
           UpdateCommand="UPDATE [Hoatdongsx] SET [madnghiep] = @madnghiep, [Tongdt] = @Tongdt, [Nam] = @Nam, [Socongnhan] = @Socongnhan,[Soca]=@Soca,[Masan]=@Masan,[Soluongsa]=@Soluongsa WHERE [mahd] = @original_mahd"
           
          OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues">
         
          <SelectParameters>
        <asp:QueryStringParameter Name="Madnghiep" QueryStringField="_iddn"  ConvertEmptyStringToNull="true"/>
     </SelectParameters> 
          <DeleteParameters>
               <asp:Parameter Name="original_mahd" Type="Int32" />
           </DeleteParameters>
           <UpdateParameters>
               <asp:Parameter Name="madnghiep" Type="Int32" />
               <asp:Parameter Name="Tongdt" Type="String" />
               <asp:Parameter Name="Nam" Type="String" />
               <asp:Parameter Name="Socongnhan" Type="Int32" />
               <asp:Parameter Name="Soca" Type="Int32" />
               <asp:Parameter Name="Masan" Type="Int32" />
               <asp:Parameter Name="Soluongsa" Type="Int32" />
               
               <asp:Parameter Name="original_mahd" Type="Int32" />
               
               
           </UpdateParameters>
           <InsertParameters>                
               
               <asp:Parameter Name="madnghiep" Type="Int32" />
               <asp:Parameter Name="Tongdt" Type="String" />
               <asp:Parameter Name="Nam" Type="String" />
               <asp:Parameter Name="Socongnhan" Type="Int32" />
               <asp:Parameter Name="Soca" Type="Int32" />
               <asp:Parameter Name="Masan" Type="Int32" />
               <asp:Parameter Name="Soluongsa" Type="Int32" />
              
           </InsertParameters>
          
      </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource_hdsx1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:QLMTConnectionString %>" 
            SelectCommand="SELECT [mahd], [TenDN], [Tongdt], [Nam], [Socongnhan], [Soca], [Masan], [Soluongsa] FROM [Hoatdongsx]">
        </asp:SqlDataSource>
        
         <asp:SqlDataSource ID="hdsx_dn" runat="server" 
           ConnectionString="<%$ ConnectionStrings:QLMTConnectionString %>" 
           SelectCommand="SELECT * FROM [Doanhnghiep] where Madnghiep=@Madnghiep">
          <SelectParameters>
        <asp:QueryStringParameter Name="Madnghiep" QueryStringField="_iddn"  ConvertEmptyStringToNull="true"/>
     </SelectParameters>
         </asp:SqlDataSource>
        
               <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor1" runat="server" TextBoxStyle-Width="200px" />
       <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor2" runat="server" TextBoxStyle-Width="150px" />
       <telerik:GridDropDownListColumnEditor ID="GridDropDownColumnEditor1" runat="server" DropDownStyle-Width="110px" />
       <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server" NumericTextBox-Width="40px" />
    </div>
    </form>
</body>
</html>